package com.totcy.atom.presenter;

import android.content.Context;

import com.totcy.atom.bean.GankTypeBean;
import com.totcy.atom.model.GankTypeListModel;
import com.totcy.atom.presenter.contract.GankTypeListContract;
import com.totcy.baselibrary.base.mvpbase.BasePresenterImpl;

import java.util.List;

/**
 * description: gank分类列表 presenter
 *
 * @author : Totcy
 *         date: 2017/11/2 14:48
 *         update: 2017/11/3
 */

public class GankTypeListPresenter extends BasePresenterImpl<GankTypeListContract.View, GankTypeListContract.Model> implements GankTypeListContract.Presenter {

    public GankTypeListPresenter(Context context) {
        super(context);
    }

    @Override
    public GankTypeListModel attachModel() {
        return new GankTypeListModel(mContext);
    }

    @Override
    public void getGankTypeData(String type, int pageSize, int curPage) {
        if (isModelAttached()) {
            getModel().getGankTypeData(type, pageSize, curPage, new GankTypeListContract.Model.DataCallback() {
                @Override
                public void onDataSuccess(List<GankTypeBean> bean) {
                    if (isViewAttached()) {
                        getView().onGankTypeData(bean);
                    }
                }

                @Override
                public void onDataNotAvailable() {
                    if (isViewAttached()) {
                        getView().onDataFail();
                    }
                }
            });
        }
    }

}
